package com.etone.smartAudit.controller;


import com.etone.smartAudit.annotation.LoginAdmin;
import com.etone.smartAudit.domain.Admin;
import com.etone.smartAudit.domain.CertificateGroup;
import com.etone.smartAudit.service.CertificateGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 存证单群组信息  前端控制器
 * </p>
 *
 * @author jiayen
 * @since 2021-06-08
 */
@Api(value = "群组操作", tags = "存证单群组操作")
@RestController
public class CertificateGroupController {
    @Autowired
    private CertificateGroupService groupService;

    /**
     * 添加群组
     */
    @ApiOperation(value = "添加群组", tags = "jiayen")
    @PostMapping("/certificateGroup/add")
    public void addGroup(@ApiIgnore @LoginAdmin Admin admin,
                         @ApiParam("群组名称") @RequestParam String groupName, @ApiParam("群组类型,1-需求单群组，2-确认单群组") @RequestParam Integer type
            , @ApiParam("关联的项目id") @RequestParam Integer itemId) {
        groupService.addGroup(admin, groupName, type, itemId);
    }

    @ApiOperation(value = "获取群组列表", tags = "jiayen")
    @GetMapping("/certificateGroup/list")
    public List<CertificateGroup> getGroupList(@ApiParam("群组类型,1-需求单群组，2-确认单群组") @RequestParam Integer type
            , @ApiParam("关联的项目id 传0则获取所有") @RequestParam Integer itemId) {

        return groupService.getGroupList(type, itemId);
    }
}
